package com.qys.livesMall.event.listener;

import com.qys.livesMall.app.user.event.UserFriendEvent;
import com.qys.livesMall.app.user.model.dto.sys.UserFriendEventDTO;
import com.qys.livesMall.app.user.service.AppUserFriendService;
import lombok.RequiredArgsConstructor;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;

/**
 * Created by IntelliJ IDEA.
 * User: dp
 * Date: 2023/06/08
 * Time: 10:18
 * DESCRIPTION: 用户好友监听
 */
@RequiredArgsConstructor
public class UserFriendListener {

    private final AppUserFriendService userFriendService;

    @Async
    @Order
    @EventListener(UserFriendEvent.class)
    public void userFriend(UserFriendEvent event) {
        UserFriendEventDTO dto = (UserFriendEventDTO) event.getSource();
        userFriendService.saveUserFriend(dto);
    }
}
